<template>
    <view class="">
        <!-- 头部 -->
		<pagehead>{{ userInfo.phone?'修改手机号':'绑定手机号' }}</pagehead>
        <view class="form-warp">
        <view class="form-box">
					<view class="form-item" v-if="userInfo.phone">
						<view class="form-item-label">
							登录手机号
						</view>
						<view class="form-item-inner">{{userInfo.phone | conceal(4)}}</view>
					</view>
								<view class="form-item">
						<view class="form-item-label">
							{{ userInfo.phone?'新手机号':'手机号' }}
						</view>
						<u--input class="form-item-inner" :placeholder="userInfo.phone?'请输入新手机号':'请输入手机号'" type="text" customStyle="marginLeft:40rpx;marginRight:40rpx;"
							border="none" v-model="form.tuCode">
						</u--input>
					</view>
					<view class="form-item">
						<view class="form-item-label">
							图形验证码
						</view>
						<u--input class="form-item-inner" placeholder="请输入图形验证码" type="text" customStyle="marginLeft:40rpx;marginRight:40rpx;"
							border="none" v-model="form.tuCode">
						</u--input>
						<image :src="IMAGE_STATIC+'/images/code.jpg'" class="tuCode" mode=""/>
					</view>
					<view class="form-item">
						<view class="form-item-label">
							验证码
						</view>
						<u--input class="form-item-inner" placeholder="请输入验证码" type="text" customStyle="marginLeft:40rpx;marginRight:40rpx;"
							border="none" v-model="form.code">
						</u--input>
						<view class="form-item-code" @click="sendCode()"><text class="code">{{ remain }}</text></view>
					</view>
        </view>
        <view class="submit" @tap.stop="submit()">
					确定
				</view>
			</view>
    </view>
</template>

<script>
export default {
    data () {
        return {
            isSend:true,
            remain:'获取验证码',
            form:{
                tuCode: '',
                code: '',
            },
            addstatus: false,
            userInfo:uni.getStorageSync('USERINFO')?uni.getStorageSync('USERINFO'):{phone:'1385258689758'}
        };
    },
    onLoad () {

    },
    methods: {
        // 发送验证码
        sendCode() {
            if(this.isSend == true){
                uni.showLoading({
                    title: '发送中',
                    mask: true
                });
                var data = {};
                this.phone = this.userInfo.phone;
                data['account'] = this.phone;
                data['validateType'] = 1;
                data['bizType'] = 4;
                // if(this.phone.indexOf("@") >-1){
                // 	data['type'] = 6;
                // }
                // if(this.phone.indexOf("@") <0){
                // 	data['type'] = 5;
                // }
                console.log("data：",data);
                this.$Ajax('/app/send/msgAuthCode',
                data,
                res => {
                        this.isSend = false;
                        this.remain = this.time + 's';
                        this.uuid = res.data
                        this.timer = setInterval(() => {
                            this.time--;
                            this.remain = this.time + 's';
                            if (this.time == 0) {
                                clearInterval(this.timer);
                                this.remain = '重新获取';
                                (this.isSend = true), (this.time = 60);
                            }
                        }, 1000);
                    }
                )
                uni.hideLoading();
            }
        },
        submit(){
            let that = this;
            if(!that.form.tuCode){
                return that.$tools.toast('请输入图形验证码');
            }
            if(!that.form.code){
                return that.$tools.toast('请输入验证码');
            }
            let userBankQo = {
                "tuCode": that.form.tuCode,
                "code": that.form.code,
            }
            that.$Ajax('/editPayass',userBankQo,res => {
                if (res.code == 200) {
                    that.$tools.toastBack(res.msg,1);
                }
            })
        }
    },
};
</script>

<style lang="scss" scoped>
@import '@/common/scss/operate';
</style>
